package com.photoeditor.demo.model.bean;

import android.content.res.Resources;

import com.billing.base.svip.SVipManager;
import com.common.base.ComponentContext;
import com.photoeditor.R;
import com.photoeditor.demo.model.subscribe.manager.AppVipManager;

import java.util.ArrayList;

public class EmojiPageBean {

    //类型  1， 2, 3, 4
    private int mType;

    //标识这一页属于这个emoji包的第几页
    private int mEmojiPageIndex;

    //当前Emoji APK的包名
    private String mPkgName;

    //这一页的一行的Emoji数目
    private int mColNum;

    //这一页的一列的Emoji数目
    private int mPageEmojiNum;

    //两行之前的间距
    private int mVerticalSpacing = ComponentContext.getContext().getResources().getDimensionPixelSize(R.dimen.image_edit_emoji_item_margin);

    //两列之间的间距
    private int mHorizontalSpacing;

    private ArrayList<EmojiBean> mEmojiBean;

    private boolean mNeedRefresh;

    private int mGuideDrawableId;

    private String mGuideTitle;

    private String mGuideDes;

    private String mGuideBtText;

    private String mDownUrl;

    //这两个字段外置的才存在
    private String mSaveDir;
    private String mSaveName;

    //一个的Emoji的宽度
    private int mEmojiWidth = ComponentContext.getContext().getResources().getDimensionPixelSize(R.dimen.image_edit_emoji_item_size);

    //一个的Emoji的高度
    private int mEmojiHeight = ComponentContext.getContext().getResources().getDimensionPixelSize(R.dimen.image_edit_emoji_item_size);

    //一个的item的宽度
    private int mItemWidth = ComponentContext.getContext().getResources().getDimensionPixelSize(R.dimen.default_button_size);

    //一个的item的高度
    private int mItemHeight = ComponentContext.getContext().getResources().getDimensionPixelSize(R.dimen.default_button_size);

    //一个的page的高度
    private int mPageHeight;

    //emoji pannel的背景颜色  2016-9-28新增
    private int mBgColor;

    //当前emoji是否需要vip
    private boolean mIsNeedBuy;


    public static final int TYPE_RESOURCES = 1;
    public static final int TYPE_INSTALL_EMOJI_APK = 2;
    public static final int TYPE_INSTALL_APK = 3;
    public static final int TYPE_UNINSTALL_APK = 4;
    public static final int TYPE_GUIDE_DOWNLOAD = 5;
    public static final int TYPE_GUIDE_UPDATE = 6;
    public static final int TYPE_RECENT = 7;
    public static final int TYPE_AR_STICKER = 8;
    public static final int TYPE_GIF = 9;
    public static final int TYPE_ONLINE = 10;//网络未下载数据

    /**
     * 用于TYPE_GUIDE_DOWNLOAD和TYPE_GUIDE_UPDATE
     * @param type
     * @param index
     * @param pkgName
     */
    public EmojiPageBean(int type, int index, String pkgName){
        mType = type;
        mEmojiPageIndex = index;
        mPkgName = pkgName;
        mBgColor = ComponentContext.getContext().getResources().getColor(R.color.white_top_mask_color);
    }

    /**
     * 用于TYPE_RESOURCES和TYPE_INSTALL_APK  TYPE_UNINSTALL_APK  TYPE_RECENT  TYPE_INSTALL_EMOJI_APK
     * @param type
     * @param index
     * @param pkgName
     * @param colNum
     * @param emojiNum
     * @param verticalSpacing
     * @param horizontalSpacing
     * @param emojiWidth
     * @param emojiHeight
     * @param itemWidth
     * @param itemHeight
     * @param pageHeight
     * @param isNeedBuy
     */
    public EmojiPageBean(int type, int index, String pkgName, int colNum, int emojiNum,
                         int verticalSpacing, int horizontalSpacing,
                         int emojiWidth, int emojiHeight,
                         int itemWidth, int itemHeight, int pageHeight, int bgColor, boolean isNeedBuy){
        mType = type;
        mEmojiPageIndex = index;
        mPkgName = pkgName;
        mColNum = colNum;
        mPageEmojiNum = emojiNum;
        mVerticalSpacing = verticalSpacing;
        mHorizontalSpacing = horizontalSpacing;
        mEmojiWidth = emojiWidth;
        mEmojiHeight = emojiHeight;
        mItemWidth = itemWidth;
        mItemHeight = itemHeight;
        mPageHeight = pageHeight;
        mBgColor = bgColor;
        mIsNeedBuy = isNeedBuy;
    }

    public boolean isType(int type){
        return (mType == type);
    }

    public int getType() {
        return mType;
    }

    public int getEmojiPageIndex() {
        return mEmojiPageIndex;
    }

    public String getPkgName() {
        return mPkgName;
    }

    public int getColNum() {
        return mColNum;
    }

    public int getPageEmojiNum() {
        return mPageEmojiNum;
    }

    public int getVerticalSpacing() {
        return mVerticalSpacing;
    }

    //如果是Guide type则需要设置Guide res
    public void setGuideRes(int guideDrawableId, String guideTitle, String guideDes, String guideBtText, String downUrl, String dir, String name){
        mGuideDrawableId = guideDrawableId;
        mGuideTitle = guideTitle;
        mGuideDes = guideDes;
        mGuideBtText = guideBtText;
        mDownUrl = downUrl;
        mSaveDir = dir;
        mSaveName = name;
    }

    //如果是Guide type则需要设置Guide res
    public void setGuideRes(int guideDrawableId, int guideTitleId, int guideDesId, int guideBtTextId, String downUrl, String dir, String name){
        Resources res = ComponentContext.getContext().getResources();
        mGuideDrawableId = guideDrawableId;
        mGuideTitle = res.getString(guideTitleId);
        mGuideDes = res.getString(guideDesId);
        mGuideBtText = res.getString(guideBtTextId);
        mDownUrl = downUrl;
        mSaveDir = dir;
        mSaveName = name;
    }

    //如果是Guide type则需要设置Guide res  如果是GP的下载链接则调用这个
    public void setGuideRes(int guideDrawableId, int guideTitleId, int guideDesId, int guideBtTextId, String downUrl){
        Resources res = ComponentContext.getContext().getResources();
        mGuideDrawableId = guideDrawableId;
        mGuideTitle = res.getString(guideTitleId);
        mGuideDes = res.getString(guideDesId);
        mGuideBtText = res.getString(guideBtTextId);
        mDownUrl = downUrl;
    }

    public String getDownUrl() {
        return mDownUrl;
    }

    public void setDownUrl(String downUrl) {
        mDownUrl = downUrl;
    }

    public int getGuideDrawableId() {
        return mGuideDrawableId;
    }

    public String getGuideTitle() {
        return mGuideTitle;
    }

    public String getGuideDes() {
        return mGuideDes;
    }

    public String getGuideBtText() {
        return mGuideBtText;
    }

    public ArrayList<EmojiBean> getEmojiBean() {
        return mEmojiBean;
    }

    public void setEmojiBean(ArrayList<EmojiBean> emojiBean) {
        this.mEmojiBean = emojiBean;
    }

    public boolean isNeedRefresh() {
        return mNeedRefresh;
    }

    public void setNeedRefresh(boolean needRefresh) {
        this.mNeedRefresh = needRefresh;
    }

    public String getSaveDir() {
        return mSaveDir;
    }

    public String getSaveName() {
        return mSaveName;
    }

    public int getEmojiWidth() {
        return mEmojiWidth;
    }

    public int getEmojiHeight() {
        return mEmojiHeight;
    }

    public int getItemHeight() {
        return mItemHeight;
    }

    public int getItemWidth() {
        return mItemWidth;
    }

    public int getPageHeight() {
        return mPageHeight;
    }

    public int getBgColor() {
        return mBgColor;
    }

    public void setBgColor(int mBgColor) {
        this.mBgColor = mBgColor;
    }

    public boolean isNeedBuy() {
        return mIsNeedBuy && !AppVipManager.isVip();
    }
}
